const wallBoxs = document.querySelectorAll('.wall-box>img'),
    wallAud = document.getElementById("wallAud"),
    wallMoves = document.querySelectorAll('.wall-move>img'),
    // wallWrapper = document.querySelector('.wall-wrapper'),
    subtitle = document.querySelector('.subtitle');

let titleArr = [
    "作为一名大学生 看着那些和我",
    "年纪相仿的青年奋斗在前线",
    "他们担当起了时代的使命",
    "给自己的青春书写了与众不同的篇章",
    "而此时此刻坐在家里的我 内心是羡慕的",
    "我羡慕他们能够有这样的能力 ",
    "和责任 奋战前线体验非凡的人生",
    "感受生命的意义",
    "说实话， 我想逆行",
    "可我又有什么本领去抗“ 疫” 呢",
    "我能做好的无非是保护好自己",
    "从而保护好家人",
    "只有勤学苦干增长才干 才能用科学精神和专业本领",
    "保护好想保护的人",
    "用读书积蓄力量， 用行动肩负责任",
    "用拼搏昭示希望",
    "大学的青春不能缺少过硬的本领",
    "学好过硬的本领来回应时代和责任担当",
    "这才是我们当代大学生",
    "真正应该去做好的事"
];

// wallAnimation();
function wallAnimation(){
    const backTime = setTimeout(function() {
	    for (let i = 0; i < wallBoxs.length; i++) {
	        wallBoxs[i].style.animation = " wallbox 3s forwards";
	        wallMoves[i].style.animation = "wallmove 3s forwards";
	        wallMoves[i].style.animationDelay = i * 3 + "s";
	        wallBoxs[i].style.animationDelay = i * 3 + "s";
	    }
	    Backchange();
	    clearTimeout(backTime);
    }, 1500);
	
    Titlechange();
	
    function Titlechange() {
	    let titindex = 0;
	    const titeTimer = setInterval(function() {
	        subtitle.innerHTML = titleArr[titindex];
	        titindex++;
	        // console.log(titindex * 3)
	        if (titindex > titleArr.length - 1) {
	            titindex = titleArr.length - 1;
	            clearInterval(titeTimer);
	        }
	    }, 3000);
	
    };
	
    function Backchange() {
	    let index = 0;
	    let wallArr = [];
	    for (let i = 0; i < wallBoxs.length; i++) {
	        wallArr.push(wallBoxs[i].src)
	    }
	    let timer = setInterval(function() {
	        subtitle.innerHTML = titleArr[index];
	        wallWrapper.style.background = "url(" + wallArr[index] + ") no-repeat";
	        wallWrapper.style.backgroundSize = "cover";
	        wallWrapper.style.backgroundPosition = "center";
	        if (index >= wallArr.length - 1) {
	            index = wallArr.length - 1;
	            clearInterval(timer)
	        }
	        index++;
	    }, 3000);
    }
};

